home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
lin_alg.lha
/
lin_alg
/
vmatrix.dat
< prev
next >
Wrap
Text File
|
1993-08-08
|
4KB
|
136 lines
-------------------------------------------------------------------------------
Verify Operations on Matrices
---> Test allocation and compatibility check
The following matrices have been allocated
Matrix 1:4x1:20 'Matrix m1'
Matrix 1:4x1:20 'Matrix m2'
Matrix 1:4x0:19 'Matrix m3'
Matrix 1:4x1:20 'Matrix m4'
Status information reported for matrix m3:
Row lower bound ... 1
Row upper bound ... 4
Col lower bound ... 0
Col upper bound ... 19
No. rows ...........4
No. cols ...........20
No. of elements ....80
Name Matrix m3
Check matrices 1 & 2 for compatibility
Check matrices 1 & 4 for compatibility
m2 has to be compatible with m3 after resizing to m3
m1 has to be compatible with m5 after resizing to m5
Matrix 1:5x1:25 'Matrix m5'
---> Test operations that treat each element uniformly
Writing zeros to m...
Clearing m1 ...
Comparing m1 with 0 ...
Writing a pattern 8.625 by assigning to m(i,j)...
Writing the pattern by assigning to m1 as a whole ...
Comparing m and m1 ...
Comparing (m=0) and m1 ...
Clear m and add the pattern
add the doubled pattern with the negative sign
subtract the trippled pattern with the negative sign
Verify comparison operations
(m=pattern)>0
(m=pattern)>-pattern
(m=-pattern)<-pattern/2
Assign 2*pattern to m by repeating additions
Assign 2*pattern to m1 by multiplying by two
Multiply m1 by one half returning it to the 1*pattern
Assign -pattern to m and m1
m = sqrt(sqr(m)); m1 = abs(m1); Now m and m1 have to be the same
Check out to see that sin^2(x) + cos^2(x) = 1
Element (16,8) with value 1 differs the most from what
was expected, 1, though the deviation 1.19209e-07 is small
Done
---> Test Binary Matrix element-by-element operations
Verify assignment of a matrix to the matrix
Adding the matrix to itself, uniform pattern 4.25
subtracting two matrices ...
subtracting the matrix from itself
adding two matrices together
Arithmetic operations on matrices with not the same elements
adding mp to the zero matrix...
making m = 3*mp and m1 = 3*mp, via add() and succesive mult
clear both m and m1, by subtracting from itself and via add()
Testing element-by-element multiplications and divisions
squaring each element with sqr() and via multiplication
compare (m = pattern^2)/pattern with pattern
Comparison of two Matrices:
Matrix 2:11x0:19 ''
Matrix 2:11x0:19 ''
Maximal discrepancy 0
occured at the point (2,0)
Matrix 1 element is 4.25
Matrix 2 element is 4.25
Absolute error v2[i]-v1[i] 0
Relative error 0
||Matrix 1|| 850
||Matrix 2|| 850
||Matrix1-Matrix2|| 0
||Matrix1-Matrix2||/sqrt(||Matrix1|| ||Matrix2||) 0
Done
---> Verify norm calculations
Assign 10.25 to all the elements and check norms
1. (col) norm should be pattern*nrows
Inf (row) norm should be pattern*ncols
Square of the Eucl norm has got to be pattern^2 * no_elems
Done
---> Verify determinant evaluation
for a square matrix of size 20
Check to see that the determinant of the unit matrix is one
determinant is 1
Check the determinant for the matrix with 2.5
at the diagonal
determinant is 9.09495e+07
Check the determinant for the matrix with 2.5
at the anti-diagonal
Check the determinant for the singular matrix
defined as above with zero first row
determinant is 0
Check out the determinant of the Hilbert matrix
3x3 Hilbert matrix: exact determinant 1/2160
computed 1/2159.99
4x4 Hilbert matrix: exact determinant 1/6048000
computed 1/6.04788e+06
5x5 Hilbert matrix: exact determinant 3.749295e-12
computed 3.75127e-12
7x7 Hilbert matrix: exact determinant 4.8358e-25
computed 6.54014e-25
9x9 Hilbert matrix: exact determinant 9.72023e-43
computed -1.10127e-39
10x10 Hilbert matrix: exact determinant 2.16418e-53
computed -3.15323e-47
Done